import book.BookList;
import user.Administrator;
import user.RegularUsers;
import user.User;

import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: DELL
 * Date: 2022-08-23
 * Time: 21:07
 * name: 实现图书系统的主体
 */
public class Main {

    public static User login() {

        System.out.println("请输入姓名：");
        Scanner scanner = new Scanner(System.in);
        String username = scanner.nextLine();
        System.out.println("请输入你的身份： 1. 管理员  2. 用户");
        int choose = scanner.nextInt();
        if (choose == 1) {
            return new Administrator(username);  // 利用向上转型直接返回用户类型和姓名
        } else {
            return new RegularUsers(username);  //  利用向上转型直接返回用户类型和姓名
        }
    }

    public static void main(String[] args) {

        //0. 准备数据
        BookList bookList = new BookList();
        //1.登录图书系统
        User user = login();  //user 对象可以为管理员或者用户

        while(true){

            int choose = user.menu();

            user.doOperation(choose,bookList);
        }

    }
}
